﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.ComponentModel;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    public partial class TEK08
    {
        public TEK08()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VEKADR();
            this.DataContext = MV;
            InitializeComponent();
        }

        public override void LOADBYAUF()
        {
            TBMain.Clear();
            base.LOADBYAUF();
            if (ORDERNUM.Length < 19)
                return;
             
            dwData = TBMain.Clone().NewRow();
            dwData["EKAMANDANT"] = app.Mandant;
            dwData["EKAAUFKRS"] = ORDERNUM.Substring(1, 2);
            dwData["EKAAUFLFD"] = ORDERNUM.Substring(3, 6);
            dwData["EKAAUFPOS"] = ORDERNUM.Substring(9, 3);
            SResult = TMV.QEKA01(dwData);
            MergeData(SResult, true, true);
            //if (!IsEdit)
              //  return;
            if (!IsAuto)
                return;
            if (TBMain.Rows.Count == 0)
            {
                PM["KASA"] = KASA;
                PM["KRS"] = ORDERNUM.Substring(1, 2);
                PM["LFD"] = ORDERNUM.Substring(3, 6);
                PM["POS"] = ORDERNUM.Substring(9, 3); 
                TMV.NEWEKADR(PM);
                vwMaster.View.MoveCurrentToFirst(); 
            }
         }
    }
}
